package com.yakumosakura.yakumoblade.data;

import com.yakumosakura.yakumoblade.Yakumoblade;
import mods.flammpfeil.slashblade.registry.slashblade.SlashBladeDefinition;
import net.minecraft.core.HolderLookup.Provider;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;


import java.util.Set;
import java.util.concurrent.CompletableFuture;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class YakumoBladeDataGen {
    @SubscribeEvent
    public static void dataGen(GatherDataEvent event) {
        DataGenerator dataGenerator = event.getGenerator();
        CompletableFuture<Provider> lookupProvider = event.getLookupProvider();
        PackOutput packOutput = dataGenerator.getPackOutput();
        ExistingFileHelper existingFileHelper = event.getExistingFileHelper();

        dataGenerator.addProvider(event.includeServer(), new YakumoBladeRecipeProvioder(packOutput));

        final RegistrySetBuilder bladeBuilder = new RegistrySetBuilder()
                .add(SlashBladeDefinition.REGISTRY_KEY,
                        context->{
            YakumoBladeBuiltInRegsitry.registerAll(context);
            YakumoBladeBuiltInRegsitryStar.registerAll(context);
            YakumoBladeBuiltInRegsitryTouHou.registerAll(context);
            YakumoBladeBuiltInRegsitryHexGram.registerAll(context);
                                 }
                 );

        dataGenerator.addProvider(event.includeServer(),
                new DatapackBuiltinEntriesProvider(packOutput, lookupProvider, bladeBuilder, Set.of(Yakumoblade.MODID)));

        //        dataGenerator.addProvider(event.includeServer(),
//                new DatapackBuiltinEntriesProvider(packOutput, lookupProvider, bladeBuilder2, Set.of(Yakumoblade.MODID)));




    }
}
